package com.example.service;

import com.example.entity.Delivery;
import com.example.mapper.DeliveryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeliveryService {

    @Resource
    DeliveryMapper deliveryMapper;

    public void add(Delivery delivery) {
        deliveryMapper.insert(delivery);
    }

    public void deleteById(Integer id) {
        deliveryMapper.deleteById(id);
    }

    public void updateById(Delivery delivery) {
        deliveryMapper.updateById(delivery);
    }

    public List<Delivery> selectAll() {
        return deliveryMapper.selectAll();
    }

    public Delivery selectById(Integer id) {
        return deliveryMapper.selectById(id);
    }

    public PageInfo<Delivery> selectPage(Integer pageNum, Integer pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        List<Delivery> list = deliveryMapper.selectAll();
        return PageInfo.of(list);
    }
}
